package org.example.seat_management.Controller.api;

import org.example.seat_management.Entity.ClassInfo;
import org.example.seat_management.Service.ClassService;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/classes")
public class ClassController {

    private final ClassService classService;

    public ClassController(ClassService classService) {
        this.classService = classService;
    }

    @PostMapping
    public Long create(@RequestBody ClassInfo classInfo) {
        return classService.create(classInfo);
    }

    @PutMapping("/{id}")
    public void update(@PathVariable Long id, @RequestBody ClassInfo classInfo) {
        classInfo.setId(id);
        classService.update(classInfo);
    }

    @DeleteMapping("/{id}")
    public void delete(@PathVariable Long id) {
        classService.delete(id);
    }

    @GetMapping
    public List<ClassInfo> listAll() {
        return classService.listAll();
    }
}


